// SimpleGLUTApplication.cpp

#include <iostream>
#include <vector>
#include <string.h>

using namespace std;

#include "AbstractGLUTWindow.h"
#include "SimpleGLUTApplication.h"

namespace Voltron
{
	SimpleGLUTApplication::SimpleGLUTApplication()
	{
		DEBUG_PRINT("SimpleGLUTApplication::SimpleGLUTApplication()\n");
		
		//_windows = new vector< ManipulatorWindow* >();  /// We'll use a singleton window for now.
		//Initialize();
	}

	SimpleGLUTApplication::~SimpleGLUTApplication()
	{
		DEBUG_PRINT("Destroying SimpleGLUTApplication\n");
	}

	int SimpleGLUTApplication::Initialize()
	{
		DEBUG_PRINT("SimpleGLUTApplication::Initialize()\n");

		// fake some argc and argv variables to hand the glutInit unfunction later
		int argc = 1;
		char *argv[1];
		
		argv[0] = strdup("SimpleGLUTApplication");
		 
		return Initialize(argc, argv);
	}


	int SimpleGLUTApplication::Initialize(int argc, char *argv[])
	{
		DEBUG_PRINT("SimpleGLUTApplication::Initialize(int argc, char *argv[])\n");

		glutInit(&argc, argv);
		
		ManipulatorWindowSingleton::Instance()->initWindow("Manipulator3D", 512,512,500,500, argv);
		
		return(0);
	}

		
	int SimpleGLUTApplication::Run()
	{
		DEBUG_PRINT("SimpleGLUTApplication::Run()\n");
	
		glutMainLoop();
		
		return(0);
	}

	int SimpleGLUTApplication::attachGLUTWindow(AbstractGLUTWindow* window)
	{
		_windows.push_back(window);
	}

	int SimpleGLUTApplication::dettachGLUTWindow(AbstractGLUTWindow* window)
	{
		// TBD
	}

}
